#!/bin/sh
#Tag 0x9039
#
# Buttonfly launcher script
#       
# Updated Tue Jul 16 20:06:40 PDT 1996 Diana Starr
# -------------------------------------------------------------
# If there are some arguments, try to run buttonfly with them.
# Check for audio flag first, 
# If remaining args not empty then assume the remaining is a path.
# Otherwise do same stuff would do if no args but add audio tag:
#
# Otherwise see if there are some menus in the local directory 
# but if not, then run from the default buttonfly location
# -------------------------------------------------------------


  if [ $# != 0 ]
    then
        if [ $1 = "-a" ]
        then 
            shift 
            if [ $1 ]
            then
              # Arguments included audio flag and hopefully remaining is a path 
              cd $*
              sh -c "/usr/demos/Demo_Interfaces/Buttonfly/buttonfly -a "

            else

              # Arguments were audio flag and no path - check for local menus 
              localdir=`pwd`
              localfiles=`ls $localdir/.menu`
              if [ $localfiles ]
              then
                 sh -c "/usr/demos/Demo_Interfaces/Buttonfly/buttonfly -a "
              else
              # Args were audio flag but no path or local menus so run default
                 cd /usr/demos/Demo_Interfaces/Buttonfly
                 sh -c "/usr/demos/Demo_Interfaces/Buttonfly/buttonfly -a"
              fi
           fi
       else 
          # Argument passed to script was a path only
          cd $*
          sh -c "/usr/demos/Demo_Interfaces/Buttonfly/buttonfly "
      fi

  else

    # No arguments passed to script
    localdir=`pwd`
    localfiles=`ls $localdir/.menu`

    if [ $localfiles ]
     then
         sh -c "/usr/demos/Demo_Interfaces/Buttonfly/buttonfly"
     else
         cd /usr/demos/Demo_Interfaces/Buttonfly
         sh -c "/usr/demos/Demo_Interfaces/Buttonfly/buttonfly"
     fi
  fi
 
